<?php
namespace app\zb\controller;

use think\Controller;

class Common extends Controller
{
    private $obj;
    function _initialize()
    {
        if (!is_weixin()) {
            $user = input('param.user');
            session('username', $user);
            switch ($user) {
                case 'popo';
                    session('userid', 1);
                    break;
                case 'lsl';
                    session('userid', 2);
                    break;
            }
            session('openid', 'o_WIcwccOaW-UdBrgeyDofcw5qO4');
            session('member_id', 426);
            session('member_username', 'USER');
        } else {
            $base_url = request()->module() . '/' . request()->controller() . '/' . request()->action();
            session('base_url', $base_url);
            session('base_param', input('param.'));

            if (!session('?openid')) {
                session('model', 'zb');
                $this->redirect('index/member/index', ['base_model' => 'zb']);
                //\app\index\controller\Common::oauth(); // 发起授权
            }

//            $member = model('Member')->get(['openid' => session('openid')]);  // 获取绑定脏户信息
//            if ($member) {  // 记录session
//                session('member_id', $member['id']);
//                session('member_username', $member['username']);
//            } else{  // 跳转到绑定页面
//                $this->redirect('index/login/index');
//            }
        }
    }
}